﻿window.downloadFileFromBytes = (fileBytes, fileName, coutentType) => {
    const uint8Array = new Uint8Array(fileBytes);
    const blob = new Blob([uint8Array], { type: coutentType });

    const url = URL.createObjectURL(blob);

    const a = document.createElement('a');
    a.href = url;
    a.download = fileName;
    document.body.appendChild(a);
    a.click();
    document.body.removeChild(a);
    URL.revokeObjectURL(url);
}

async function callDotNetMethods() {
    try {
        // 调用 GetGreetingAsync
        // 格式: DotNet.invokeMethodAsync(assemblyName, methodIdentifier)
        // methodIdentifier 可以是:
        //   - "命名空间.类名.方法名" (如果没用自定义标识符)
        //   - 或者 [JSInvokable("identifier")] 中指定的字符串
        const greeting = await DotNet.invokeMethodAsync('BlazorApp', 'GetGreetingAsync', 'Alice');
        console.log(greeting); // 输出: Hello, Alice! Welcome from .NET.

        // 调用 CalculateSum (使用自定义标识符)
        const sum = await DotNet.invokeMethodAsync('BlazorApp', 'calculateSum', 5, 3);
        console.log(sum); // 输出: 8
    } catch (error) {
        console.error('调用 .NET 方法失败:', error);
    }
}



